package com.tang.objectOriented.senior.static_;

public class StaticExercise02 {
    //编写一个main方法
    public static void main(String[] args) {
        TestPerson testPerson = new TestPerson();
        testPerson.main(args);
//        TestPerson.main(args);
    }
}

class Person {
    private int id;
    private static int total = 0;
    public static int getTotalPerson() {
        // 静态方法/类方法　只支持　类方法和类属性
        //id++;//错误, 注销

        return total;
    }
    public Person() {//构造器
        //System.out.println("total " + total++);//这里是先打印(即使用)total,打印完total后，total再自加(所以这里打印出total 0)
        total++;  //total = 1
        System.out.println("total"+total);
        id = total;//id = 1

    }
}
class TestPerson {
    public static void main(String[] args) {
        System.out.println("Number of total is " +Person.getTotalPerson()); //0
        Person p1 = new Person();
        System.out.println( "Number of total is "+ Person.getTotalPerson()); //1
    }
}
